package photo

import (
	"net/http"

	"mall/common/resultx"
	"mall/service/forum/api/internal/logic/forum/photo"
	"mall/service/forum/api/internal/svc"
	"mall/service/forum/api/internal/types"

	"github.com/zeromicro/go-zero/rest/httpx"
)

func GetPhotoByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.PhotoIdReq
		if err := httpx.Parse(r, &req); err != nil {
			resultx.ParamErrorResult(r, w, err)
			return
		}

		l := photo.NewGetPhotoByIdLogic(r.Context(), svcCtx)
		resp, err := l.GetPhotoById(&req)
		resultx.HttpResult(r, w, resp, err)
	}
}
